#include<iostream>
#include<string>
using namespace std;
const int N = 1e3 + 10, mod = 1e9 + 7;
int f[N][3];
string s;
int main()
{
	cin >> s;
	int len = s.size();
	s = " " + s;
	for (int i = 1; i <= len; i++) {
		f[i][(s[i] - '0') % 3] = 1;
	}
	for (int i = 1; i <= len; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = i + 1; k <= len; k++) {
				int a = s[k] - '0';
				f[k][(a + j) % 3] += f[i][j];
				f[k][(a + j) % 3] %= mod;
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= len; i++) {
		ans += f[i][0];
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}